﻿@page
@model IndexModel
@{
    ViewData["Title"] = "用户列表";
    ViewBag.Current = "users.index";
}

<div class="card data-list">
    <div class="card-header toolbar">
        <form method="get">
            <gt:search asp-for="Query.Name" placeholder="请输入名称"></gt:search>
        </form>
        <div class="actions">
            <gt:action-group>
                <gt:action typeof="Add" asp-page="./Create" mode="Primary">添加新用户</gt:action>
                <gt:action disabled typeof="Delete" asp-page-handler="Delete" mode="Danger"></gt:action>
            </gt:action-group>
        </div>
    </div>
    <div class="card-body pt-0">
        <table class="table table-hover">
            <thead>
                <tr>
                    <th class="checkbox"><gt:checkall /></th>
                    <th .sort="@UserOrderBy.UserName">名称</th>
                    <th>邮件地址</th>
                    <th .sort="@UserOrderBy.CreatedDate">添加时间</th>
                    <th .sort="@UserOrderBy.UpdatedDate">更新时间</th>
                    <th .sort="@UserOrderBy.LastLoginDate">最后登录</th>
                    <th class="text-center">操作</th>
                </tr>
            </thead>
            <tbody class="align-middle" .warning="Model.Items" .warning-text="未找到相关用户信息！">
                @foreach (var item in Model.Items)
                {
                    <tr class="data-item">
                        <td class="checkbox"><gt:checkbox value="@item.Id" /></td>
                        <td>
                            @(item.NickName)(@(item.UserName))
                        </td>
                        <td>@item.Email</td>
                        <td>@item.CreatedDate.ToString("f")</td>
                        <td>@item.UpdatedDate.ToString("f")</td>
                        <td>@item.LastLoginDate?.ToString("f")</td>
                        <td>
                            <gt:action-dropdownmenu>
                                <gt:action typeof="Edit" asp-page="./Edit" asp-route-id="@item.Id"></gt:action>
                                <gt:action typeof="Modal" icon="Key" asp-page="./Password" asp-route-id="@item.Id">设置密码</gt:action>
                                <gt:action typeof="Divider"></gt:action>
                                <gt:action typeof="Delete" confirm="你确定要删除“@(item.NickName)”吗？" asp-page-handler="Delete" asp-route-id="@item.Id"></gt:action>
                            </gt:action-dropdownmenu>
                        </td>
                    </tr>
                }
            </tbody>
        </table>
        <gt:page data="Model.Items" asp-route-name="@Model.Query.Name" orderby="Model.Query"></gt:page>
    </div>
</div>